{% extends "student/base.html" %}
{% block content %}
<head>
    <meta charset="UTF-8">
    <title>show_classes</title>
    <link rel="stylesheet" href="{{ STATIC_URL }}common.css">
</head>
<body>
    <table class="gridtable" align="center">
        <tbody>
            <tr>
                <th align="center">学生ID</th>
                <th align="center">课程ID</th>
                <th align="center">课程名称</th><th align="center">发表评论</th>
            </tr>
            {% for selected in result_list %}
                <tr>
                    <td>{{ selected.studentid }}</td>
                    <td>{{ selected.courseid }}</td>
                    <td>{{ selected.coursename }}</td>
                    <td>
                        <input type="text"></input>
                        <button type="submit" class="btn btn-info">提交</button>
                    </td>
                </tr>
            {% endfor %}
        </tbody>
    </table>
</body>
<script>
    function commit_comment(studentid,coursename,comment) {
        $.ajax({
            type: "get",
            url:  "{{SITE_URL}}student/add_comment/",
            data: {
             "studentid" : studentid,
             "coursename" : coursename,
             "comment" : comment,
            },
            success:function (response) {
                alert(response['message'])
            }
        })
    }
    $(":submit").click(function (){
        studentid = $(this).parent().siblings('td')[0].innerHTML
        coursename = $(this).parent().siblings('td')[2].innerHTML
        comment = $(this).siblings('input').val()
        $(this).text("已提交")
        commit_comment(studentid,coursename,comment)
    })
</script>
{% endblock %}